package cn.edu.njust.service.impl;

import cn.edu.njust.mapper.RegisterMapper;
import cn.edu.njust.mapper.ResultMapper;
import cn.edu.njust.service.TeacherService;
import cn.edu.njust.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 * -*- coding: UTF-8 -*-
 *
 * @Project: CCF-Pre-Registration-System
 * @Package: cn.edu.njust.service.impl
 * @IDE: IntelliJ IDEA
 * @File: TeacherServiceImpl.java
 * @Author: GZ-WangSong
 * @Date: 2022/12/30 20:42
 * @Description:
 */
public class TeacherServiceImpl implements TeacherService {
    SqlSessionFactory factory = SqlSessionFactoryUtils.getSqlSessionFactory();

    @Override
    /**
     * 根据条件查询预报名人数，实现数据可视化
     */
    public int[][] countByCondition() {
        //获取SqlSession对象
        SqlSession sqlSession = factory.openSession();
        //获取UserMapper
        RegisterMapper mapper = sqlSession.getMapper(RegisterMapper.class);
        int isFree = mapper.countByAdmission01();
        int selfPaying = mapper.countByAdmission00();
        return new int[][]{{1, isFree}, {2, selfPaying}};
    }
}
